#include <iostream>
using namespace std;
 
/*设计模式之模板模式*/
class borrow_book {
public:
    void run() {
        gotoRoom();
        InputBook();
        leaveRoom();
    }
protected:
    void gotoRoom() { cout << "进入房间！" << endl; }
    void leaveRoom() { cout << "离开房间！" << endl; }
    virtual void InputBook()=0;
public:
    virtual ~borrow_book() {}
};

class borrower : public borrow_book {
public:
    borrower(string book) :book(book) {}
    ~borrower() {}
private:
    virtual void InputBook() {
        cout << "我要借阅 " << book << endl;
    }
private:
    string book;
};
//主函数入口
int Template_method()
{
    borrow_book* book = new borrower("三国演义");
    book->run();
    delete book;
}

